import 'package:flutter/material.dart';
import 'package:ml_flutter/pages/home/homeviewcontroller.dart';
import 'package:ml_flutter/pages/notice/noticeviewcontroller.dart';
import 'package:ml_flutter/pages/mine/mineviewcontroller.dart';
import 'const.dart';
import 'package:dio/dio.dart';


class MLTabbarController extends StatefulWidget {
  @override
  _TabbarState createState() => _TabbarState();
}




class _TabbarState extends State<MLTabbarController> {
  int _index = 0;
  final PageController _controller = PageController(initialPage: 0);

// getRequest() async {
//     Response response = await Dio()
//         .get('https://www.wanandroid.com/banner/json');
//     this.setState(() {
//     var  result= response.toString();

//     });
//   }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
//        添加标签栏
        bottomNavigationBar: BottomNavigationBar(
            onTap: (int index) {
              _index = index;
              setState(() {});
              _controller.jumpToPage(_index);
            },
            selectedFontSize: 12,
            fixedColor: ThemColor,
            type: BottomNavigationBarType.fixed,
            currentIndex: _index,
            items: <BottomNavigationBarItem>[
              BottomNavigationBarItem(
                icon: Image(
                  image: AssetImage('images/homeGrayNew.png'),
                  height: 20,
                  width: 20,
                ),
                activeIcon: Image(
                  image: AssetImage('images/homeBlueNew.png'),
                  height: 20,
                  width: 20,
                ),
                title: Text('首页'),
              ),
              BottomNavigationBarItem(
                icon: Image(
                  image: AssetImage('images/notifyGrayNew.png'),
                  height: 20,
                  width: 20,
                ),
                activeIcon: Image(
                  image: AssetImage('images/notifyBlueNew.png'),
                  height: 20,
                  width: 20,
                ),
                title: Text('通知'),
              ),
              BottomNavigationBarItem(
                icon: Image(
                  image: AssetImage('images/myselfGrayNew.png'),
                  height: 20,
                  width: 20,
                ),
                activeIcon: Image(
                  image: AssetImage('images/myselfBlueNew.png'),
                  height: 20,
                  width: 20,
                ),
                title: Text('我'),
              ),
            ]),
//        添加控制器
        body: PageView(
          physics: NeverScrollableScrollPhysics(),
          controller: _controller,
          children: [
            MLHomeViewController(),
            MLNoticeViewController(),
            MLMineViewController()
          ],
        ),
      );

  }
}
